package com.rongma.waterdrop.utils;

import android.app.Activity;

import com.rongma.waterdrop.global.WaterDropApplication;

import java.util.LinkedList;

/**
 * 用于对Activity进行管理
 * Created by RongMa on 16/5/20.
 */
public class ActivityCollector
{
    private static LinkedList<Activity> activities = new LinkedList<Activity>();

    //添加Activity
    public static void addActivity(Activity activity)
    {
        WaterDropApplication.getApplication().setActivity(activity);
        activities.add(activity);
    }

    //删除Activity
    public static void removeActivity(Activity activity)
    {
        WaterDropApplication.getApplication().setActivity(null);
        activities.remove(activity);
    }

    //关闭所有的Activity
    public static void finishAll()
    {
        for(Activity activity : activities)
        {
            if(!activity.isFinishing())
            {
                activity.finish();
            }
        }
    }

}
